package com.vcixp.main.login.entity;

import java.util.UUID;

import org.nutz.dao.entity.annotation.ColDefine;
import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.EL;
import org.nutz.dao.entity.annotation.Name;
import org.nutz.dao.entity.annotation.Prev;
import org.nutz.dao.entity.annotation.Table;
import org.nutz.lang.Strings;

@Table("t_user")
public class User {

	@Name
	@Column("id")
	@ColDefine(width = 64)
	@Prev(els = @EL("$me.initUUID()"))
	private String id;
	@Column("username")
	@ColDefine(width = 20)
	private String username;
	@Column("password")
	@ColDefine(width = 20)
	private String password;

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String initUUID() {
		if (Strings.isEmpty(id)) {
			id = UUID.randomUUID().toString().replaceAll("-", "");
		}
		return id;
	}
}
